package com.gxa.xc.rbac.controller;

import com.gxa.xc.rbac.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

/**
 * @author:IT-CNLM
 * @date:Created at 2020/10/20
 */
@RestController
@RequestMapping("/test")
public class Test2Controller {


    @RequestMapping(path = "/index", method = {RequestMethod.POST, RequestMethod.GET})
    public String index(){
        return "test";
    }

    /**
     * 测试参数
     * @param id
     * @return
     */
    @GetMapping("/param1")
    public String param1(@RequestParam(name = "ssuuii", defaultValue = "666") Integer id){

        return id+"";
    }

    /**
     * 路径传参
     * @param id
     * @return
     */
    @GetMapping("/param2/{id}/{name}")
    public String param2(@PathVariable Integer id, @PathVariable String name){
        return "id:"+id+",名字:"+name;
    }


    /**
     * 利用对象去接收多个参数
     * @param user
     * @return
     */
    @PostMapping("/user")
    public List<User> param3(User user){
        ArrayList<User> users = new ArrayList<>();
        users.add(new User("jack","111111", new Timestamp(System.currentTimeMillis())));
        users.add(user);
        return users;
    }



}
